<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        var root = {
            name:"A",
            val:26,
            left:{
                name:"B",
                val:53,
                need:3,
                left:{
                    name:"E",
                    need:1,
                },
                right:{
                    name:"F",
                    need:5
                }
            },
            middle:{
                name:"C",
                need:1
            },
            right:{
                name:"D",
                need:4,
                val:58,
                right:{
                    name:"G",
                    need:9
                }
            }
        };
        var cat = 1000;
        var all = {
            E:1,
            F:5,
            C:1,
            G:9
        }
        function find(root){
            if(!root.left&&!root.middle&&!root.right){
                for(var key in all){
                    if(root.name==key){
                        
                    }
                }
            };
            
        }
    </script>
</body>
</html>